# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer:
pkgname=nitrocli
pkgver=0.4.1
pkgrel=3
pkgdesc="A command line tool for interacting with Nitrokey devices"
url="https://github.com/d-e-s-o/nitrocli"
arch="x86_64 x86 armhf armv7 aarch64 ppc64le" # limited by rust/cargo
license="GPL-3.0-or-later"
depends="gnupg"
checkdepends="python3" # used by the extension tests
makedepends="cargo hidapi-dev libnitrokey-dev cargo-auditable"
subpackages="$pkgname-doc $pkgname-bash-completion"
source="https://github.com/d-e-s-o/nitrocli/archive/v$pkgver/nitrocli-$pkgver.tar.gz
	src-tests-run.rs-use-python3.patch
	"


build() {
	export USE_SYSTEM_LIBNITROKEY=1
	cargo auditable build --release --locked
	cargo run --bin=shell-complete bash > nitrocli
}

check() {
	cargo test --release --locked
}

package() {
	cargo auditable install --locked --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/bin/shell-complete
	rm "$pkgdir"/usr/.crates*

	install -Dm644 -t "$pkgdir/usr/share/man/man1" \
		"$builddir/doc/$pkgname.1"

	install -Dm644 -t "$pkgdir/usr/share/bash-completion/completions" \
		"$builddir/nitrocli"
}

sha512sums="
d6d8ee1d83144c90d6b248f086176397542dd34a4f873848245a7f2796c201ded982f78f1d83f54b247bb8569fb79f54a01f4e217cd85e5b2b098c35d2abba8c  nitrocli-0.4.1.tar.gz
d2aa6258274ec427e0feb6e5f2c19bba328be3b2de4a26f5ea5b6a27f4b948e578c140a966f2a1c1e1ae160a7ef2f005cb2469cb684a22b042bbcf977621ac29  src-tests-run.rs-use-python3.patch
"
